<!-- search by distance block -->

<form method="post" action="{$rlBase}{if $config.mod_rewrite}{$pages.search_by_distance}.html{else}index.php?page={$pages.search_by_distance}{/if}">
	<input type="hidden" name="sbd_block" value="1" />
	
	<select name="block_country" style="width: 170px;">
		<option value="">{$lang.sbd_select_country}</option>
		{foreach from='countries'|df item='country'}
			{if $sbd_iso[$country.Key]}
				<option value="{$sbd_iso[$country.Key]}" {if $smarty.post.block_country == $sbd_iso[$country.Key]}selected="selected"{elseif !$smarty.post.block_country && $smarty.session.GEOLocationData->Country_code && $smarty.session.GEOLocationData->Country_code == $sbd_iso[$country.Key]}selected="selected"{/if}>{$lang[$country.pName]}</option>
			{/if}
		{/foreach}
	</select>
	
	<div style="padding: 10px 0">
			<select name="block_distance" class="w50">
				{foreach from=','|explode:$config.sbd_distance_items item='distance'}
					<option {if $smarty.post.block_distance == $distance}selected="selected"{/if} value="{$distance}">{$distance}</option>
				{/foreach}
			</select>
			
			{if $config.sbd_units == 'miles/kilometres'}
				<select name="block_distance_unit" style="width: 50px;">
					{if $config.sbd_default_units == 'miles'}
						<option value="mi" title="{$lang.sbd_mi}">{$lang.sbd_mi_short}</option>
						<option {if $smarty.post.block_distance_unit == 'km'}selected="selected"{/if} value="km" title="{$lang.sbd_km}">{$lang.sbd_km_short}</option>
					{else}
						<option value="km" title="{$lang.sbd_km}">{$lang.sbd_km_short}</option>
						<option {if $smarty.post.block_distance_unit == 'mi'}selected="selected"{/if} value="mi" title="{$lang.sbd_mi}">{$lang.sbd_mi_short}</option>
					{/if}
				</select>
			{else}
				<input name="block_distance_unit" type="hidden" value="{if $config.sbd_units == 'miles'}mi{else}km{/if}" />
				{if $config.sbd_units == 'miles'}{$lang.sbd_mi}{else}{$lang.sbd_km}{/if},
			{/if}
			
			{$lang.sbd_within}
			<input maxlength="10" name="block_zip" type="text" value="{if $smarty.post.block_zip}{$smarty.post.block_zip}{else}{$lang.sbd_zipcode}{/if}" style="width: 55px;text-align: center;" />
	</div>
	
	<input type="submit" value="{$lang.search}" />
</form>

<script type="text/javascript">
var sbd_zip_phrase = '{$lang.sbd_zipcode}';
{literal}

	$(document).ready(function(){
		$('input[name=block_zip]').focus(function(){
			if ( $(this).val() == sbd_zip_phrase )
			{
				$(this).val('');
			}
		}).blur(function(){
			if ( $(this).val() == '' )
			{
				$(this).val(sbd_zip_phrase);
			}
		});
	});
	
{/literal}
</script>

<!-- search by distance block end -->